{{template "admin/public/head.html" .}}
<section>
	<aside>
		{{template "admin/public/nav.html" .}}
	</aside>
	<article>
		<div class="top-title">
			<dl>
				<dt><h1>{{.title}}</h1></dt>
				<dd>&nbsp;</dd>
			</dl>
		</div>
		<div class="content">
			{{if eq .info.status "1"}}
			<div class="release">
				<dl>
					<dt> <p>&nbsp;</p>
					</dt>
					<dd><button type="button" class="button" id="shopcar">添加购物车</button></dd>
				</dl>
			</div>
			{{end}}
			<form class="form">

				<table class="table1">
					<!-- 控制表格宽度  横向合并 colspan="1"  竖向合并 rowspan="3" -->
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td rowspan="2" colspan="1" class="center"><img src="{{if .info.pathname}}{{.info.pathname}}{{else}}/static/img/admin/avatar.jpg{{end}}" class="uppic img-3"></td>
						<td class="genre">买家昵称</td>
						<td colspan="2"><a href="/admin/member/content?id={{.info.uid}}" class="tz">{{.info.monicker}}</a></td>
						<td class="genre">原价</td>
						<td>{{.info.price}}</td>
						<td class="genre">现价</td>
						<td>{{.info.money}}</td>
					</tr>
					<tr>
						<td class="genre">订单编号</td>
						<td colspan="2">
							{{.info.ordernum}}({{if eq .info.status "1"}}待付款{{else if eq .info.status "2"}}待发货{{else if eq .info.status "3"}}待收货
							{{else if eq .info.status "4"}}待评价{{else if eq .info.status "5"}}已完成{{else if eq .info.status "6"}}退款订单{{end}})
						</td>
						<td class="genre">支付类型</td>
						<td colspan="1">
							{{if eq .info.paytype "1"}}余额{{else if eq .info.paytype "2"}}微信{{else if eq .info.paytype "3"}}支付宝{{end}}
						</td>
						<td class="genre">操作</td>
						<td colspan="2">
							{{if eq .info.status "1"}}
							<a class="editprice tz" data-id="{{.info.id}}" data-money="{{.info.money}}">修改价格</a><br>
							<a class="del tz" data-id="{{.info.id}}">取消订单</a><br>
							{{end}}
							{{if eq .info.status "2"}}
							<a class="tz" href="/admin/order/send?id={{.info.id}}">发货</a><br>
							{{end}}
							</td>
					</tr>
					<tr>
						<td class="genre">收货人</td>
						<td colspan="1">
							{{.info.name}}
						</td>
						<td class="genre">收货人号码</td>
						<td colspan="1">
							{{.info.mobile}}
						</td>
						<td class="genre">收货人地址</td>
						<td colspan="3">
							{{.info.shen}} {{.info.shi}} {{.info.qu}} {{.info.address}}
						</td>
					</tr>
					<tr>
						<td class="genre">总件数</td>
						<td colspan="2">
							{{.info.totalNum}}
						</td>
						<td class="genre">体积</td>
						<td colspan="2">
							{{.info.tj}}立方
						</td>
						<td class="genre">重量</td>
						<td colspan="2">
							{{.info.zl}}千克
						</td>
					</tr>
					<tr>
						<td class="genre">下单时间</td>
						<td colspan="1">
							{{.info.addtime}}
						</td>
						<td class="genre">支付时间</td>
						<td colspan="1">
							{{.info.paytime}}
						</td>
						<td class="genre">发货时间</td>
						<td colspan="1">
							{{.info.shippingtime}}
						</td>
						<td class="genre">收货时间</td>
						<td colspan="1">
							{{.info.goodtime}}
						</td>
					</tr>
					<tr>
						<td class="genre">优惠券</td>
						<td colspan="1">
							{{if .coupon}}{{.coupon.name}}{{else}}未用优惠券{{end}}
						</td>
						<td class="genre">vip优惠</td>
						<td colspan="1">
							{{.info.count}}
						</td>
						<td class="genre">税款</td>
						<td colspan="1">
							{{.info.tax}}
						</td>
						<td class="genre">发票</td>
						<td colspan="7">
							{{if eq .info.invoice "0"}}不需要{{else}}需要{{end}}
						</td>
					</tr>
					{{if eq .info.invoice "1"}}
					<tr>
						<td class="genre">发票抬头</td>
						<td colspan="1">
							{{.info.look}}
						</td>
						<td class="genre">税号</td>
						<td colspan="1">
							{{.info.taxid}}
						</td>
						<td class="genre">开户行</td>
						<td colspan="1">
							{{.info.bank}}
						</td>
						<td class="genre">账户</td>
						<td colspan="1">
							{{.info.account}}
						</td>
					</tr>
					<tr>
						<td class="genre">地址</td>
						<td colspan="1">
							{{.info.cadress}}
						</td>
					</tr>
					{{end}}
					{{if eq .info.status "3" "4" "5"}}
					<tr>
						<td class="genre">司机姓名</td>
						<td colspan="3">
							{{.info.drivername}}
						</td>
						<td class="genre">司机号码</td>
						<td colspan="3">
							{{.info.drivermobile}}
						</td>
					</tr>
					<tr>
						<td class="genre" colspan="8">货单</td>
					</tr>
					{{if .info.spathname}}
					<tr>
						<td rowspan="3" colspan="3" class="center"><a href=""><img src="{{.info.spathname}}" class="uppic img-3"></a></td>
					</tr>
					{{end}}
					{{end}}
					<tr>
					{{if .pmem}}
						<td rowspan="1" colspan="1" class="center"><img src="{{if .pmem.pathname}}{{.pmem.pathname}}{{end}}" class="uppic img-3"></td>
						<td class="genre">昵称</td>
						<td><a href="/admin/member/content?id={{.info.puid}}" class="tz">{{.pmem.monicker}}</a></td>
						<td class="genre">佣金</td>
						<td colspan="1">
							{{.info.commission}}
						</td>
					{{else}}	
						<td class="genre">佣金</td>
						<td colspan="1">
							{{.info.commission}}
						</td>
					{{end}}
						<td class="genre">工厂折扣(总)</td>
						<td colspan="1">
							{{.info.totalFoldPrice}}
						</td>
					</tr>
				</table>
			</form>
		</div>
		<style type="text/css">
			.numinput{width: 100px;text-align: center;}
		</style>
		<div class="content">	
			<div class="form">

				<table class="table">
					<!-- 控制表格宽度  横向合并 colspan="1"  竖向合并 rowspan="3" -->
					<thead><th width="15%">商品信息</th><th width="30%"></th><th width="30%"></th><th width="15%"></th></thead>
					{{range .product}}
					<tr id="{{.id}}">
						<td class="center"><a href="/admin/product/content?id={{.pid}}" class="tz"><img src="{{.pathname}}" class="img-1"></a></td>

						<td>
							产品标题：<a href="/admin/product/content?id={{.pid}}" class="tz">{{.title}}</a><br>
							型号：{{.model}}{{.id}}<br>
							{{if eq .spec "0"}}
							购买单价：&yen;{{.pprice}}/箱<br>
							购买总价：&yen;{{.ppriceall}}/箱<br>
							{{else}}
							购买单价：&yen;{{.price}}/件<br>
							{{end}}
							{{if .brandFoldPriceCell}}
							品牌街折扣后(单价)：&yen;{{.brandFoldPriceCell}}
							{{end}}
						</td>
						<td>
							{{if eq $.info.status "1"}}
							购买数量：<input value="{{.num}}" data-oid="{{$.info.id}}" data-id="{{.id}}" class="numinput" type="number">{{if eq .spec "0"}}箱{{else}}件{{end}}<br>
							{{else}}
							购买数量：{{.num}}{{if eq .spec "0"}}箱{{else}}件{{end}}<br>
							{{end}}
							发货数量：{{.sendnum}}{{if eq .spec "0"}}箱{{else}}件{{end}}<br>
							{{if eq $.admin_gid "0"}}
							提货司机：{{if .monicker}}<a href="/admin/member/content?id={{.did}}" class="tz">{{.monicker}}</a>{{end}}
							{{end}}<br>
							体积：{{.tj}}<br>
							重量：{{.weight}}<br>
						</td>
						<td class="operation">
							{{if eq $.info.status "1"}}
							<a class="delcar" data-id="{{.id}}" data-oid="{{$.info.id}}">删除</a><br>
							{{end}}
							{{if eq $.admin_gid "0"}}
							状态：{{if eq .status "1"}}待备货{{else if eq .status "2"}}待取货{{else if eq .status "3"}}待发货{{else if eq .status "4"}}已发货{{end}}<br>
							{{if .monicker}}
							已分配司机<br>
							{{else}}
							<a class="tz driver" data-id="{{.id}}" id="{{.id}}">分配司机</a><br>
							{{end}}
							{{end}}
							{{if eq .status "3" "4" "5"}}
							{{if ne .num .sendnum}}
							{{if eq .return "0"}}
							<a class="tz return" data-id="{{.id}}" data-oid="{{$.info.id}}" data-rprice="{{.rprice}}">退款(&yen;{{.rprice}})</a><br>
							{{else}}
							已退款<br>
							{{end}}
							{{end}}
							{{end}}
						</td>
					</tr>
					{{end}}
				</table>
			</div>
		</div>
		
		<div class="mask">
		<div class="mask-content">
			<form id="parameter">
				<table class="table1">
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td class="genre" colspan="2">原价</td>
						<td colspan="6">
							<input type="text" class="input95" placeholder="请输入要修改的价格！" readonly="" id="money">
						</td>
					</tr>
					<tr>
						<td class="genre" colspan="2">价格</td>
						<td colspan="6">
							<input type="text" class="input95" placeholder="请输入要修改的价格！" name="price">
						</td>
					</tr>
				</table>
				<input type="hidden" name="id">
			</form>
			<p id="tip"></p>
			<div class="mask-form">
				<dl>
					<dt>
						<button id="qr">保存</button>
						<button id="cancle">取消</button>
					</dt>
					<dd>
					</dd>
				</dl>
			</div>
		</div>
	</div>
	<div class="shopcar">
		<div class="mask-content">
			<form id="shopcarform">
				<table class="table1">
					<thead><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th><th width="10%"></th><th width="15%"></th></thead>
					<tr>
						<td class="genre" colspan="2">产品</td>
						<td colspan="6"><input type="text" class="input70" placeholder="产品id" name="pid" list="pid">
							<datalist id="pid">
							</datalist>
							<button type="button" class="inputbutton" data-type="product">搜索产品</button>
						</td>
					</tr>
					<tr>
						<td class="genre" colspan="2">数量</td>
						<td colspan="6">
							<input type="number" class="input95" placeholder="请输入数量！" name="num" value="1">
						</td>
					</tr>
				</table>
				<input type="hidden" name="uid" value="{{.info.uid}}">
				<input type="hidden" name="oid" value="{{.info.id}}">
			</form>
			<p id="tip"></p>
			<div class="mask-form">
				<dl>
					<dt>
						<button id="shopcar_qr">保存</button>
						<button id="shopcar_cancle">取消</button>
					</dt>
					<dd>
					</dd>
				</dl>
			</div>
		</div>
	</div>
	<style type="text/css">
		.shopcar{position: fixed;top: 0;left: 0;background-color: rgba(0,0,0,0.3);z-index: 1000;width: 100vw;height: 100vh;display: none;}
		.shopcar .mask-content{width: 80%;z-index: 100001;position: absolute;left: 10%;top:calc(50vh - 100px);}
		.shopcar .mask-content .mask-form dl dt button {overflow: hidden; border: none; float: left; letter-spacing: 3px; font-size: 14px; padding: 10px 15px; margin: 10px 10px 0 0; line-height: 20px !important; border-radius: 3px; vertical-align: top; background: #a87848; color: #fff; font-weight: 900; }
		.mask-form{overflow:hidden;}
		/*.shopcar{position: fixed;top: 0;left: 0;background-color: rgba(0,0,0,0.3);z-index: 10000;width: 100vw;height: 100vh;display: block;}*/
		/*.shopcar{position: fixed;top: 0;left: 0;background-color: rgba(0,0,0,0.3);z-index: 10000;width: 100vw;height: 100vh;display: block;}*/
	</style>
	<style type="text/css">
		.maskdriver{position: fixed;top: 0;left: 0;background-color: rgba(0,0,0,0.3);z-index: 10000;width: 100vw;height: 100vh;display: none;}
		.maskdriver ul{height: 40vh;width: 150px;position: absolute;top: 30vh;left: calc(50% - 75px);z-index: 10001;background: #fff;
			overflow-y: scroll;padding: 15px}
		.maskdriver ul li{width: 100%;overflow:hidden;padding: 5px 0;border-bottom: 1px solid #eee}
		.maskdriver ul li img{width: 40px;height: 40px;float: left;}
		.maskdriver ul li div{width:calc(100% - 40px)height:40px;float: left;}
		.maskdriver ul li div p{line-height: 20px;font-size: 14px;padding-left: 10px}
		.maskdriver ul li div p:nth-of-type(2){font-size: 12px;color: #666}
	</style>
	<div class="maskdriver">
		<ul>
			{{range .driver}}
			<li class="driverlist" data-id="{{.id}}" data-monicker="{{.monicker}}">
				<img src="{{.pathname}}">
				<div>
					<p>{{.monicker}}</p>
					<p>{{.name}}</p>
				</div>
			</li>
			{{end}}
		</ul>
	</div>
	</article>
</section>

<footer><!-- 系统监控内容 --></footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/jquery.jedate.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/toast.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/uppic.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/app.js"></script>
<script>
    console.log({{.product}})
	$('#shopcar').click(function(){
		$('.shopcar').show()
	})
	// $('.shopcar').click(function(){
	// 	$(this).hide()
	// })
	$('#shopcar_cancle').click(function(){
		$('.shopcar').hide()
		$('#shopcarform').find('input[name="num"]').val(1)
		$('#shopcarform').find('input[name="pid"]').val('')
	})
	$('#shopcar_qr').click(function(){
		if(!$('#shopcarform').find('input[name="num"]').val()){
			wxc.xcConfirm("请输入数量","info");
			return
		}
		if(!$('#shopcarform').find('input[name="pid"]').val()>0){
			wxc.xcConfirm("请输入产品id","info");
			return
		}
		var form=$('#shopcarform').serialize()
		console.log(form)
		$.ajax({
			url:'/admin/order/shopcar_add',
			data:form,
			success:function(res){	
				if(res==0){
					wxc.xcConfirm("添加失败","error");
				}else if(res==1){
					wxc.xcConfirm("添加成功","success",{onClose:function(){
						history.go(0)
					}});
				}else if(res==2){
					wxc.xcConfirm("输入不正确","error");
				}else{
					wxc.xcConfirm("权限不足","error");
				}
			}
		})
		

	})
	var id;
	$('.driver').click(function(){
		id=$(this).attr('data-id')
		var scrolltop=$(window).scrollTop()-20
		var offset=$(this).offset()
		var height=$('.maskdriver ul').height()
		var wheight=$(window).height()
		$('.maskdriver ul').css('left',offset.left)
		var top=offset.top-scrolltop
		if(top+height>wheight){
			top=top-height-40
		}
		$('.maskdriver ul').css('top',top)
		$('.maskdriver').show()
	})
	$('.maskdriver').click(function(){
		$(this).hide()
	})
	$('.driverlist').click(function(){
		var did=$(this).attr('data-id')
		var monicker=$(this).attr('data-monicker')
		$.ajax({
			url:'/admin/order/driver',
			data:{id:id,did:did},
			success:function(res){
				if(res==1){
					/*$('#'+id).attr('class','tz')
					$('#'+id).attr('href','/admin/member/content?id='+did)
					$('#'+id).html(monicker)*/
					history.go(0)
				}else{
					wxc.xcConfirm("操作失败,请重试","error");
				}
			}
		})
	})
	$('.editprice').click(function(){
		var id=$(this).attr('data-id')
		var money=$(this).attr('data-money')
		$('#money').val(money)
		$('input[name="id"]').val(id)
		$('.mask').css('display','block')
	})
	$('#cancle').click(function(){
		$('#money').val('')
		$('input[name="id"]').val('')
		$('input[name="price"]').val('')
		$('.mask').css('display','none')
	})
	$('#qr').click(function(){
		var form=$('#parameter').serialize()
		$.ajax({
			url:'/admin/order/edit',
			data:form,
			success:function(res){
				if(res==1){
					history.go(0)
				}else{
					wxc.xcConfirm("操作失败,请重试","error");
				}
			}
		})
	})

    $('.del').click(function(){
		var id=$(this).attr('data-id');
		wxc.xcConfirm("您确定要取消这笔订单吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/del',
				data:{table:'mt_order',id:id},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('取消成功');
						$('#'+id).css('display','none');
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	}) 

	$('.delcar').click(function(){
		var id=$(this).attr('data-id');
		var oid=$(this).attr('data-oid');
		wxc.xcConfirm("您确定要删除该购物车吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/order/shopcar_del',
				data:{id:id,oid:oid},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('删除成功');
						$('#'+id).css('display','none');
					}else if(res==2){
						wxc.xcConfirm("无购物车数据,订单取消","info",{onClose:function(){
							window.location.href=document.referrer
						}});
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
		}});
	})
	$('.numinput').change(function(){
		var id=$(this).attr('data-id');
		var oid=$(this).attr('data-oid');
		var num=$(this).val();
		$.ajax({
				url:'/admin/order/shopcar_change',
				data:{id:id,oid:oid,num:num},
				type:'get',
				success:function(res) {
					if(res==1){
						showMessage('修改成功');
					}else {
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})	
	})
	$('.return').click(function(){
		var id=$(this).attr('data-id');
		var oid=$(this).attr('data-oid');
		var rprice=$(this).attr('data-rprice');
		wxc.xcConfirm("您确定要退款吗?","confirm",{onOk:function(){
			$.ajax({
				url:'/admin/order/return_outofstock',
				data:{id:id,oid:oid,rprice:rprice},
				success:function(res) {
					if(res==1){
						history.go(0)
					}else{
						wxc.xcConfirm("操作失败,请重试","error");
					}
				}
			})
		}});
	})
</script>
</body>
</html>
